package com.zzl.ov_library.tools;

import org.springframework.stereotype.Component;

@Component
public class WechatTools {


//    @Bean
    public static String getOpenid(String code, String appid, String secret) {
        // 调用接口必要的参数
        StringBuilder data = new StringBuilder();
        // appid、secret定义在配置文件中，注入到项目里
        data.append("appid=" + appid + "&");
        data.append("secret=" + secret + "&");
        data.append("js_code=" + code + "&");
        data.append("grant_type=" + "authorization_code");

        String response = HttpUtils.getRequest("https://api.weixin.qq.com/sns/jscode2session?" + data);


        return response;
    }

}
